/////precompiled////////
#include "precompiled.h"
////////////////////////


#include "prs_TDotPath.h"
using namespace prs;

// TDotPath ///////////////////////////////////////////////////////////////////

//
void TDotPath::Execute(svl::TString SPath)
{
  a.Clear();

  char *S = SPath;
  int   L = lstrlen(S);
  int   Pos = 0;

  for (int N = 0; N < L; N++)
  {
    if (S[N] == '.')
    {
      if (N - Pos > 0) // node
      {
        svl::TString SName; SName.Add(S+Pos,N-Pos);
        a.Add(new TItem(SName));
      }
      Pos = N + 1;
    }
    else if (N + 1 == L) // leaf
    {
      svl::TString SName; SName.Add(S+Pos,N-Pos+1);
      a.Add(new TItem(SName));
    }
  }
}

//
svl::TString TDotPath::MakeSPath()
{
  svl::TString S; for (int N = 0; N < Count(); N++)
  {
    S << (*this)[N]; if (N + 1 < Count()) { S << ".";}
  }
  return S;
}
